package com.yunao.service.impl;

import com.yunao.commons.serachcore.core.bean.*;
import com.yunao.dao.ReportDao;
import com.yunao.entity.Report;
import com.yunao.service.IsearchService;
import com.yunao.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ReportDao reportDao;

    @Autowired
    IsearchService service;

    @Override
    public Report get(int id) {
        return reportDao.findById(id).get();
    }

    @Override
    public void save(Report entity) {
        reportDao.save(entity);
    }

    @Override
    public void save(List<Report> entities) {
        reportDao.saveAll(entities);
    }

    @Override
    public void delete(int id) {
        reportDao.deleteById(id);
    }


    @Override
    public void saveOrUpdate(Report entity) {
        reportDao.save(entity);
    }

    @Override
    public List<Report> findAllByUserIdAndMannerAndAloneReportId(Integer userId, Integer manner, Integer aloneReportId, Pageable pageable) {
        return reportDao.findAllByUserIdAndMannerAndAloneReportId(userId,manner,aloneReportId,pageable);
    }

    @Override
    public List<Report> findAllByAloneReportIdAndUserId(String aloneReportId, String userId, Pageable pageable) {
        return reportDao.findAllByAloneReportIdAndUserId(aloneReportId,userId,pageable);
    }

    @Override
    public List<Report> findAllByNameAndUserId(String name, Integer userId) {
        return reportDao.findAllByNameAndUserId(name,userId);
    }

    @Override
    public List<Report> findAllByNameAndAddrs(String name, String addrs) {
        return reportDao.findAllByNameAndAddrs(name,addrs);
    }

    @Override
    public Long countByMannerAndAloneReportIdAndUserId(Integer manner, Integer aloneReportId, Integer userId) {
        return reportDao.countByMannerAndAloneReportIdAndUserId(manner,aloneReportId,userId);
    }

    @Override
    public Articles query(Map map) {
        return service.query(map);
    }

    @Override
    public Cubes cube(Map map) {
        return service.cube(map);
    }

    @Override
    public Clusters cluster(Map map) {
        return service.cluster(map);
    }

    @Override
    public Wordclouds wordcloud(Map map) {
        return service.wordcloud(map);
    }

    @Override
    public Groups groups(Map map) {
        return service.group(map);
    }


}
